package cn.edu.zafu.bigdata.x.zhouyuyan.work7;

public class checkScore {
    public checkScore(int score) throws InvalidScoreException{
        if (score<0 || score>100){
            throw new InvalidScoreException("分数无效：分数小于0或大于100。");
        }else{
            System.out.println("分数有效：分数为"+score+"分。");
        }
    }

    public static void main(String[] args) {
        java.util.Scanner scanner = new java.util.Scanner(System.in);
        try{
            System.out.println("请输入一个0到100之间的分数：");
            int score = scanner.nextInt();
            new checkScore(score);
        }catch (InvalidScoreException e){
            System.err.println("错误:"+e.getMessage());
        }finally {
            scanner.close();
        }
    }
}
